package defectsim.integrator.velocitylaw;

import javax.vecmath.Vector2d;

import repast.simphony.parameter.Parameters;

import defectsim.SimulationEnvironment;
import defectsim.agents.Dislocation;

public class ThermalDampingVelocity implements VelocityLaw{

	private SimulationEnvironment environment = SimulationEnvironment.getInstance();
	private double temperature;
	
	public ThermalDampingVelocity(){
		Parameters p = environment.getParameters();
		this.temperature = (Double)p.getValue("temperature");	
	}
	
	@Override
	public Vector2d getVelocity(Dislocation da, Vector2d force) {
		double ToverTheta = temperature / 343.5;
		double dampingCoefficient = (ToverTheta + 0.0095 * Math.pow(ToverTheta, 4)) * 3.75e-5;
		return new Vector2d(force.x / dampingCoefficient, 
							force.y * 0.01 / dampingCoefficient);
	}
}
